package aerouacmsla.interfazDeUsuario;

import aerouacmsla.procedimientos.BDConexion;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
/**
 *
 * @author Marco
 */
public class VentanaUsuario extends javax.swing.JFrame {

    private JFrame padre;
    private BDConexion miConexion;
    private String idUsuario;

    public VentanaUsuario() {
        initComponents();
        jTabbedPane1.setComponentAt(1, new VentanaRegistroPasajero().getPanelPrincipalRegistroPasajero());
    }
    public VentanaUsuario(JFrame padre, BDConexion miConexion, String usuario, String nombreDeUsuario) {
        initComponents();
        setMiConexion(miConexion);
        setPadre(padre);
        setIdUsuario(nombreDeUsuario);
        panelAtenderPasajeros1.setMiConexion(getMiConexion());
        panelRegistroPasajero1.setMiConexion(getMiConexion());
        panelAtenderPasajeros1.setIdUsuario(getIdUsuario());
        panelAtenderPasajeros1.setPanelPadre(jTabbedPane1);
        panelVentas1.setMiConexion(miConexion);
        panelVentas1.setIdUsuario(getIdUsuario());
        nombreUsuario.setText(usuario);
        jTabbedPane1.setComponentAt(1, new VentanaRegistroPasajero(getMiConexion(),jTabbedPane1).getPanelPrincipalRegistroPasajero());

    }

    public JFrame getPadre() {
        return padre;
    }

    public void setPadre(JFrame padre) {
        this.padre = padre;
    }

    public BDConexion getMiConexion() {
        return miConexion;
    }

    public void setMiConexion(BDConexion miConexion) {
        this.miConexion = miConexion;
    }

    public String getIdUsuario() {
        return idUsuario;
    }

    public void setIdUsuario(String idUsuario) {
        this.idUsuario = idUsuario;
    }

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        buttonGroup1 = new javax.swing.ButtonGroup();
        topPanel = new javax.swing.JPanel();
        jLabel3 = new javax.swing.JLabel();
        jLabel1 = new javax.swing.JLabel();
        nombreUsuario = new javax.swing.JLabel();
        jTabbedPane1 = new javax.swing.JTabbedPane();
        panelAtenderPasajeros1 = new aerouacmsla.interfazDeUsuario.PanelAtenderPasajeros();
        panelRegistroPasajero1 = new aerouacmsla.interfazDeUsuario.PanelRegistroPasajero();
        panelVentas1 = new aerouacmsla.interfazDeUsuario.PanelVentas();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Bienvenido");
        setIconImage(new ImageIcon(getClass().getResource("/Recursos/IconoUsuario32px.png")).getImage());
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowClosing(java.awt.event.WindowEvent evt) {
                formWindowClosing(evt);
            }
        });

        topPanel.setBackground(new java.awt.Color(51, 51, 51));

        jLabel3.setFont(new java.awt.Font("Tahoma", 0, 18));
        jLabel3.setForeground(new java.awt.Color(255, 255, 255));
        jLabel3.setText("Aerolinea MSLA");

        jLabel1.setForeground(new java.awt.Color(255, 255, 255));
        jLabel1.setText("Atiende:");

        nombreUsuario.setForeground(new java.awt.Color(255, 255, 0));
        nombreUsuario.setText("Usuario");

        javax.swing.GroupLayout topPanelLayout = new javax.swing.GroupLayout(topPanel);
        topPanel.setLayout(topPanelLayout);
        topPanelLayout.setHorizontalGroup(
            topPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(topPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel3)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jLabel1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(nombreUsuario)
                .addContainerGap(465, Short.MAX_VALUE))
        );
        topPanelLayout.setVerticalGroup(
            topPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(topPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel3)
                .addContainerGap(33, Short.MAX_VALUE))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, topPanelLayout.createSequentialGroup()
                .addContainerGap(41, Short.MAX_VALUE)
                .addGroup(topPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(nombreUsuario))
                .addContainerGap())
        );

        jTabbedPane1.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                jTabbedPane1StateChanged(evt);
            }
        });
        jTabbedPane1.addTab("Atender", panelAtenderPasajeros1);
        jTabbedPane1.addTab("Registrar Pasajero", panelRegistroPasajero1);
        jTabbedPane1.addTab("Ventas de Hoy", panelVentas1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(topPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addGroup(layout.createSequentialGroup()
                .addGap(10, 10, 10)
                .addComponent(jTabbedPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 670, Short.MAX_VALUE)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(topPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jTabbedPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 489, Short.MAX_VALUE)
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void formWindowClosing(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosing
        if (getPadre() != null){
            getPadre().setVisible(true);
        }
    }//GEN-LAST:event_formWindowClosing

    private void jTabbedPane1StateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_jTabbedPane1StateChanged
        if (jTabbedPane1.getSelectedIndex() == 2){
            panelVentas1.actualizarTabla();
        }
    }//GEN-LAST:event_jTabbedPane1StateChanged

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new VentanaUsuario().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.ButtonGroup buttonGroup1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JTabbedPane jTabbedPane1;
    private javax.swing.JLabel nombreUsuario;
    private aerouacmsla.interfazDeUsuario.PanelAtenderPasajeros panelAtenderPasajeros1;
    private aerouacmsla.interfazDeUsuario.PanelRegistroPasajero panelRegistroPasajero1;
    private aerouacmsla.interfazDeUsuario.PanelVentas panelVentas1;
    private javax.swing.JPanel topPanel;
    // End of variables declaration//GEN-END:variables

}
